<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="lib/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="lib/ajaxfileupload.js"></script>
</head>

<body>

	<div id="index">
		<div id="fileInput">
			选择上传的文件：
			<div><input id="file1" type="file" name="file1" /></div>
			<div><input id="file2" type="file" name="file2" /></div>
			<div><input id="file3" type="file" name="file3" /></div>
			<div><input id="file4" type="file" name="file4" /></div>
			<input onclick="uploadFile()" type="button" value="点击上传" />
		</div>
		<div id="imgs"></div>

	</div>

	<script>
		var params = {
			url: "../../file/fileUpload.do", // 文件上传地址
		};
		function uploadFile() {
			fileUpload(params.url, ["file1","file2","file3","file4"], null, function(data) {
				console.log(data);
				var $imgs = $("#imgs");
				$imgs.html("");
				/* for(i in data.data) {
					$imgs.append($("<img />").attr("src","../../file/fileDownload.do?id=" + data.data[i]));
				} */
			});
		}

		function fileUpload(url, fileElementId, params, successFun) {
			$.ajaxFileUpload({
				url: url, //用于文件上传的服务器端请求地址
				secureuri: false, //是否需要安全协议，一般设置为false
				fileElementId: fileElementId, //文件上传域的ID
				dataType: 'json', //返回值类型 一般设置为json
				data: params, //自定义参数
				success: function(data, status) { //服务器成功响应处理函数
					successFun(data);
				},
				error: function(data, status, e) { //服务器响应失败处理函数
					alert("提示信息：" + e);
				}
			})
		}
	</script>
</body>

</html>